<?php include("include/header.php");
?>
<style>
    .whiteBg,.whiteBg *{
        background:#fff !important;
        outline:none !important;
    }
</style>
<iframe name="ifr" id="ifr" style="display:none"></iframe>
<section id="content">
    <section class="hbox stretch">
        <section>
            <section class="vbox">
                <section class="scrollable padder">
                    <div class="m-b-md">
                        <h3 class="m-b-none"></h3>
                    </div>
                    <ul class="breadcrumb">
                        <li><a href="index.php?c=main"><i class="fa fa-home"></i> 首页</a></li>
                        <li><a href="index.php?c=manage&m=other_list"><i class="fa fa-list-ul"></i> 账号管理</a></li>
                        <li class="active">其他列表</li>
                    </ul>
                    <?php if ($_SESSION["user_type"] == 2) { ?>
                        <div class="row m-b-sm">
                            <div class="col-sm-5">
                                <a href="index.php?c=manage&m=other_add" class="btn btn-s-md btn-success">手动添加帐号</a>
                            </div>
                            <div class="col-sm-7">
                                <form   class="form-horizontal" method="post" enctype="multipart/form-data" action="index.php?c=manage&m=other_import">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">批量导入账号</label>
                                        <div class="col-sm-10">
                                            <input type="file" name="userfile" class="filestyle" data-icon="false" data-classButton="btn btn-default" data-classInput="form-control inline v-middle input-s">
                                            <input type="submit" class="btn btn-s-sm btn-success" value="提交">
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    <?php } ?>
                    <form method="get" action="index.php" id="search_form">
                        <input type="hidden" name="c" value="manage"/>
                        <input type="hidden" name="m" value="other_list"/>
                        <input type="hidden" name="isexport" value="1">
                        <input type="hidden" name="ids" value="">
                        <div class="m-b-sm clearfix">
                            <div class="col-sm-3" style="margin-bottom: 10px;">
                                <div class="ksearch" style="float:none !important">
                                    <h2>名称搜索：</h2>  
                                    <div class="input-group" style="border-radius:17px;border:2px solid gray;overflow:hidden;">
                                        <div class="input-group-btn">
                                            <button style="display:none" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                                                <span class="dropdown-label"> <?php echo $s_name_type != 2 ? "账号名称" : "供应商编号" ?></span>
                                            </button>
                                            
                                        </div>
                                        <input onblur="javascript:$('#search_form').submit()" type="text" name="s_name" value="<?php echo $s_name ?>" class="form-control input-sm no-border" placeholder="账号关键词">
                                        <span class="input-group-btn whiteBg">
                                            <button type="submit" class="btn btn-sm bg-white b-white btn-icon"><i class="fa fa-search"></i></button>
                                        </span>


                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-9"></div>
                            <div class="col-sm-12">
                                <h2>筛选搜索：</h2>
                                <h5>分&nbsp;&nbsp;&nbsp;&nbsp;类：</h5>
                                <div class="btn-group" data-toggle="buttons">
                                    <?php foreach ($type_list as $k => $v) { ?>
                                        <label class="btn btn-primary <?php echo in_array($v["id"], $s_type_ids) ? "active" : "" ?>">
                                            <input type="checkbox" name="s_type_ids[]" autocomplete="off" <?php echo in_array($v["id"], $s_type_ids) ? "checked" : "" ?> value="<?php echo $v['id'] ?>" > <?php echo $v["type_name"] ?>
                                        </label>
                                    <?php } ?>
                                </div>  

                                <h5>价&nbsp;&nbsp;&nbsp;&nbsp;格：</h5>
                                <div class="btn-group" data-toggle="buttons">
                                    <label class="btn btn-primary <?php echo $s_price != 2 ? "active" : "" ?>" id="s_price1">
                                        <input type="radio" name="s_price" value="1" id="" autocomplete="off" <?php echo $s_price != 2 ? "checked" : "" ?>>不限
                                    </label>
                                    <label class="btn btn-primary  <?php echo $s_price == 2 ? "active" : "" ?>"  id="s_price2">
                                        <input type="radio" name="s_price" value="2" autocomplete="off" <?php echo $s_price == 2 ? "checked" : "" ?>>价格限制
                                    </label>
                                </div>
                                <input type="text" name="s_price_start" value="<?php echo $s_price_start ?>" <?php echo $s_price != 2 ? "disabled" : "" ?> />
                                至
                                <input type="text" name="s_price_end" value="<?php echo $s_price_end ?>" <?php echo $s_price != 2 ? "disabled" : "" ?>/>


                                <h5>粉丝数：</h5>
                                <div class="btn-group" data-toggle="buttons">
                                    <label class="btn btn-primary <?php echo $s_fans != 2 ? "active" : "" ?>" id="s_fans1">
                                        <input type="radio" name="s_fans" value="1"  autocomplete="off" <?php echo $s_fans != 2 ? "checked" : "" ?>>不限
                                    </label>
                                    <label class="btn btn-primary <?php echo $s_fans == 2 ? "active" : "" ?>" id="s_fans2">
                                        <input type="radio" name="s_fans" value="2"   autocomplete="off" <?php echo $s_fans == 2 ? "checked" : "" ?>>数量限制
                                    </label>
                                </div>
                                <input type="text" name="s_fans_start" value="<?php echo $s_fans_start ?>" <?php echo $s_fans != 2 ? "disabled" : "" ?> />
                                至
                                <input type="text" name="s_fans_end" value="<?php echo $s_fans_end ?>" <?php echo $s_fans != 2 ? "disabled" : "" ?> />
                                <div class="row" style="margin-top:10px;">
                                    <div class="col-sm-2">
                                        <button class="form-control btn-success" type="submit">确定</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                    <section class="panel panel-default ">
                        <header class="panel-heading">其他账号管理</header>
                        <form method="get" action="index.php" id="delete_form">
                            <input type="hidden" name="c" value="manage"/>
                            <input type="hidden" name="m" value="other_delete"/>
                            <input type="hidden" name="del_ids" value="">

                            <table class="table table-striped m-b-none  table-hover text-center showTable">
                                <thead>
                                    <tr style="visibility:hidden">
                                        <td width="3%"></td>
                                        <td width="20%"></td>
                                        <td width="20%"></td>
                                        <td width="15%"></td>
                                        <td width="5%"></td>
                                        <td width="10%"></td>
                                        <td width="10%"></td>
                                        <td width="12%"></td>
                                        <td width="5%"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <button class="form-control btn-success" id="export" onclick="javascript:do_export();
                                                    return false;">导出</button>
                                        </td>
                                        <td colspan="2">
                                        <?php if ($_SESSION["user_type"] == 2) { ?>
                                            <button style="width:120px" class="form-control  btn-danger" id="export" onclick="javascript:do_export('delete_form');
                                                    return false;">批量删除</button>
                                        <?php }?>
                                        </td>
                                        <td colspan="8"></td>
                                    </tr>
                                    <tr >
                                        <td colspan="12" class="text-left">
                                            <strong>共<?= $count ?>个账号</strong>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="10"><input style="width:15px;" type="checkbox"  class="form-control"/></td>
                                        <td width="30"><strong>账号名称</strong></td>
                                        <td width="70"><strong>简介</strong></td>
                                        <td width="40"><strong>地址</strong></td>
                                        <td width="20"><strong>案例</strong></td>
                                        <td width="20"><strong>原创直发</strong></td>
                                        <td width="30"><strong>合作须知</strong></td>
                                        <?php if ($_SESSION["user_type"] == 2) { ?>
                                            <td width="20"><strong>联系方式</strong></td>
                                        <?php } ?>
                                        <td width="20"><strong>操作</strong></td>
                                    </tr>
                                </thead>
                                <tbody>
                                <!-- 设置头像所在td的样式 -->
                                <style>
                                 .showTable{
                                        table-layout:fixed;
                                        width:100% ;
                                    }
                                    td{
                                        padding:8px !important;
                                        word-break:break-all !important;
                                    }
                                    .avatarTd{
                                        position:relative;      
                                        padding:0;

                                    }
                                    .avatarTd img{
                                        width:200px;
                                    }
                                    .avatarTd .accountName{
                                        position:absolute;
                                        bottom:-2px;
                                        left:50%;
                                        transform:translateX(-50%);
                                        width:200px;
                                        text-align:center;
                                        background:rgba(0,0,0,.6);
                                        color:white;                                        padding:5px 0;

                                    }
                                </style>    
                                    <?php foreach ($res as $k => $row) { ?>
                                        <tr>
                                            <td><input style="max-width:15px;"  type="checkbox" name="id[]" class="form-control" value="<?= $row["id"] ?>"/></td>
                                            <td class="avatarTd">
                                                <?php if(!empty($row['head_img'])) { ?>
                                                    <img src="<?= $row['head_img'] ?>" alt="" />
                                                <?php } ?>
                                                <p class="<?php if(!empty($row['head_img'])) { echo accountName; }?>"><?= $row['account_name'] ?></p>
                                            </td>
                                            <td><?= $row['description'] ?></td>
                                            <td><a href="<?= $row['address'] ?>"><?= $row['address'] ?></a></td>
                                            <td><a href="<?= $row['case'] ?>" target="_blank">点击</a></td>
                                            <td><?= $row['original_price'] ?></td>
                                            <td><?= $row['ps'] ?></td>
                                            <?php if ($_SESSION["user_type"] == 2) { ?>
                                                <td><?= $row['contact'] ?></td>
                                            <?php } ?>
                                            <td class="text-right">
    <?php if ($_SESSION["user_type"] == 2) { ?>
                                                    <div class="btn-group">
                                                        <a title="编辑" href="index.php?c=manage&m=other_edit&id=<?= $row['id'] ?>" class="dropdown-toggle"><i class="fa fa-pencil"></i></a>
                                                            <?php if ($_SESSION['user_type'] == "2") { ?>
                                                            <a title="删除帐号" onclick="return confirm('是否将此永久删除?')" href="index.php?c=manage&m=other_delete&id=<?= $row['id'] ?>"><i class="i i-cross2"></i></a>
                                                    <?php } ?>
                                                    </div>
    <?php } ?>
                                            </td>
                                        </tr>
<?php } ?>
                                </tbody>
                            </table>
                        </form>
                    </section>
<?= $pager ?>
                    <!--<ul class="pagination pagination-sm m-t-none m-b-none">
                      <li><a href="#"><i class="fa fa-chevron-left"></i></a></li>
                      <li><a href="#">1</a></li>
                      <li><a href="#">2</a></li>
                      <li><a href="#">3</a></li>
                      <li><a href="#">4</a></li>
                      <li><a href="#">5</a></li>
                      <li><a href="#"><i class="fa fa-chevron-right"></i></a></li>
                    </ul>-->
                </section>
            </section>
        </section>
    </section>
</section>
<?php include("include/footer.php"); ?>
<script type="text/javascript">
    $(function () {
        $("#s_price1").click(function () {
            $("input[name=s_price_start]").attr("disabled", "disabled");
            $("input[name=s_price_end]").attr("disabled", "disabled");
        })
        $("#s_price2").click(function () {
            $('input[name=s_price_start]').removeAttr("disabled");//去除input元素的disabled属性
            $("input[name=s_price_end]").removeAttr("disabled");
        })
        $("#s_fans1").click(function () {
            $("input[name=s_fans_start]").attr("disabled", "disabled");
            $("input[name=s_fans_end]").attr("disabled", "disabled");
        })
        $("#s_fans2").click(function () {
            $("input[name=s_fans_start]").removeAttr("disabled");
            $("input[name=s_fans_end]").removeAttr("disabled");
        })
        
        
        
        //点击展开描述
        $("#form1").delegate(".show_btn","click",function(){
            $(this).parent().find("div").slideDown();
            $(this).hide();
        })
    })
    function do_export(action) {
        var ids_string = "";
        $('input[name="id[]"]:checked').each(function () {
            if (ids_string == "") {
                ids_string += $(this).val();
                return true;
            }
            ids_string += "," + $(this).val();
        });
        if(action=="delete_form"){
            var res =  confirm('是否将此永久删除?');
            if(res){
                $('input[name=del_ids]').val(ids_string);
                $("#delete_form").submit();
            }
        }else{
            $('input[name=ids]').val(ids_string);
            $('input[name=isexport]').val(2);
            $("#search_form").submit();
            $('input[name=isexport]').val(1);
            $('input[name=ids]').val("");
        }
    }
</script>
<script src="js/file-input/bootstrap-filestyle.min.js"></script>